CREATE TABLE IF NOT EXISTS  [WINDOW_DETAILS] ([Client_Id] varchar(50), [Window_Name] varchar, [Left] varchar(50), [Top] varchar(50), [Width] varchar(50), [Height] varchar(50));
DELETE FROM SYS_PARAMETER WHERE ParameterID = 26 AND ClientID ='DEFAULT';
DELETE FROM SYS_PARAMETER WHERE ParameterID = 27 AND ClientID ='DEFAULT';
DELETE FROM SYS_PARAMETER WHERE ParameterID = 28 AND ClientID ='DEFAULT';
DELETE FROM SYS_PARAMETER WHERE ParameterID = 29 AND ClientID ='DEFAULT';
DELETE FROM SYS_PARAMETER WHERE ParameterID = 30 AND ClientID ='DEFAULT';
DELETE FROM SYS_PARAMETER WHERE ParameterID = 31 AND ClientID ='DEFAULT';
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (26,'TRUE','DEFAULT');
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (27,'15','DEFAULT');
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (28,'TRUE','DEFAULT');
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (29,'FALSE','DEFAULT');
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (30,'FALSE','DEFAULT');
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (31,'FALSE','DEFAULT');
DELETE FROM SYSPARAMMASTER WHERE ID = 26;
DELETE FROM SYSPARAMMASTER WHERE ID = 27;
DELETE FROM SYSPARAMMASTER WHERE ID = 28;
DELETE FROM SYSPARAMMASTER WHERE ID = 29;
DELETE FROM SYSPARAMMASTER WHERE ID = 30;
DELETE FROM SYSPARAMMASTER WHERE ID = 31;
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (26,'AutoLock');
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (27,'AutoLockTime');
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (28,'Notification');
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (29,'ShowSysTime');
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (30,'ShowShortcutBar');
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (31,'MultiScreenChart');
DELETE FROM ATTRIBUTE_MASTER where ATTRIBUTE_ID in ( '9', '11');
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID,ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_DESCRIPTION,ATTRIBUTE_CODE) VALUES ('9','MARGIN', 'Product_Type','Equity,Derivative','MARGIN');
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID,ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_DESCRIPTION,ATTRIBUTE_CODE) VALUES ('11','INTRADAY', 'Product_Type','Equity,Derivative','INTRADAY');
DELETE FROM OrderEntryPreferences WHERE ClientID ='DEFAULT' AND Attribute ='KeepOrderEntryOpen';
INSERT INTO OrderEntryPreferences ('Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES ('KeepOrderEntryOpen', 'FALSE', 'DEFAULT', 'FALSE', 'KeepOrderEntryOpen');
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_TYPE = 'URLS_FROM_SERVER';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES('74','URLS_FROM_SERVER','URLS_FROM_SERVER','to get urls from server file', 'TRUE');
delete from INSTRUMENT_MASTER where SEGMENT_ID = '5' AND INSTRUMENT_NAME = "FUTIDX";
delete from INSTRUMENT_MASTER where INSTRUMENT_ID = '32';
Insert into INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) values(32,'5',"FUTIDX");
delete from INSTRUMENT_MASTER where SEGMENT_ID = '5' AND INSTRUMENT_NAME = "OPTCOM";
delete from INSTRUMENT_MASTER where INSTRUMENT_ID = '30';
Insert into INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) values(30,'5',"OPTCOM");
DELETE from OrderEntryPreferences WHERE ID='13';
Insert into OrderEntryPreferences(ID,Attribute,Value,ClientID,CODE,Description) values ('13','Dis_Qty','','DEFAULT','','');
DELETE from MarketWatchLimits WHERE parameter ='LIMIT';
Insert into MarketWatchLimits(ID,ClientID,Parameter,value,BCode,FCode,Conditionalpar) values ('1','DEFAULT','LIMIT','52','#00FFFFFF','#00FFFFFF','G');
Insert into MarketWatchLimits(ID,ClientID,Parameter,value,BCode,FCode,Conditionalpar) values ('2','DEFAULT','LIMIT','-52','#00FFFFFF','#00FFFFFF','G');
Insert into MarketWatchLimits(ID,ClientID,Parameter,value,BCode,FCode,Conditionalpar) values ('3','DEFAULT','LIMIT','1','#00FFFFFF','#00FFFFFF','L');
Insert into MarketWatchLimits(ID,ClientID,Parameter,value,BCode,FCode,Conditionalpar) values ('4','DEFAULT','LIMIT','-1','#00FFFFFF','#00FFFFFF','L');
delete from EXCHANGE_MASTER where EM_EXCH_ID='4';
insert into EXCHANGE_MASTER('EM_EXCH_ID', 'EM_EXCHANGE_NAME') values ('4','NCDEX');
delete from INSTRUMENT_MASTER where SEGMENT_ID='6';
insert into INSTRUMENT_MASTER('INSTRUMENT_ID', 'SEGMENT_ID','INSTRUMENT_NAME') values ('19','6','FUTCOM');
insert into INSTRUMENT_MASTER('INSTRUMENT_ID', 'SEGMENT_ID','INSTRUMENT_NAME') values ('34','6','FUTIDX');
delete from ORDER_MASTER where OM_EXCHSEG_CODE='46';
delete from ORDER_MASTER where OM_ID='43';
delete from ORDER_MASTER where OM_ID='44';
delete from ORDER_MASTER where OM_ID='45';
delete from ORDER_MASTER where OM_ID='46';
insert into ORDER_MASTER('OM_ID', 'OM_EXCHSEG_CODE', 'ORD_CODE', 'ORD_TYPE', 'ORD_FLAG') values ('43', '46', 'L', 'Limit', 'B');
insert into ORDER_MASTER('OM_ID', 'OM_EXCHSEG_CODE', 'ORD_CODE', 'ORD_TYPE', 'ORD_FLAG') values ('44', '46', 'MKT', 'Market', 'B');
insert into ORDER_MASTER('OM_ID', 'OM_EXCHSEG_CODE', 'ORD_CODE', 'ORD_TYPE', 'ORD_FLAG') values ('45', '46', 'SL', 'SL', 'B');
insert into ORDER_MASTER('OM_ID', 'OM_EXCHSEG_CODE', 'ORD_CODE', 'ORD_TYPE', 'ORD_FLAG') values ('46', '46', 'SL-M', 'SL-M', 'B');
delete from SEGMENT_MASTER where EX_EXCH_ID='4';
insert into SEGMENT_MASTER('SEGMENT_ID','EX_EXCH_ID', 'SEGMENT_NAME','SEGMENT_CODE') values ('6','4','COM','M');
delete from Validity_Mapping where [Attribute_ID] = 1 AND [ExchSegCode] = 46;
delete from Validity_Mapping where [Attribute_ID] = 2 AND [ExchSegCode] = 46;
delete from Validity_Mapping where [Attribute_ID] = 44 AND [ExchSegCode] = 46;
delete from Validity_Mapping where [Attribute_ID] = 40 AND [ExchSegCode] = 46;
delete from Validity_Mapping where [Attribute_ID] = 41 AND [ExchSegCode] = 46;
insert into Validity_Mapping('Attribute_ID','ExchSegCode') values ('1','46');
insert into Validity_Mapping('Attribute_ID','ExchSegCode') values ('2','46');
insert into Validity_Mapping('Attribute_ID','ExchSegCode') values ('44','46');
insert into Validity_Mapping('Attribute_ID','ExchSegCode') values ('40','46');
insert into Validity_Mapping('Attribute_ID','ExchSegCode') values ('41','46');
DELETE FROM OrderEntryPreferences WHERE ClientID ='DEFAULT' AND Attribute ='MinOdrQty';
INSERT INTO OrderEntryPreferences ('Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES ('MinOdrQty', '1', 'DEFAULT', '1', 'min order qty only for equity');
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_TYPE = 'CLient_Type' AND ATTRIBUTE_NAME = 'Pro';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES('76','Pro','CLient_Type','pro', '1');
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'CONFIRM' AND ATTRIBUTE_TYPE = 'Order_Status';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES ('77','CONFIRM','Order_Status','For GTT Orderbook','GTT');
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'TRIGGERED' AND ATTRIBUTE_TYPE = 'Order_Status';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES ('78','TRIGGERED','Order_Status','For GTT Orderbook','GTT');
CREATE TABLE [OrderEntryPreferencesTemp] ( [ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Attribute] VARCHAR(200), [Value] varchaR(100), [ClientID] varCHAR(150), [CODE] varCHAR(100), [Description] vaRCHAR);
insert into OrderEntryPreferencesTemp select * from OrderEntryPreferences where [ClientID]!='';
drop table OrderEntryPreferences;
alter table OrderEntryPreferencesTemp rename to OrderEntryPreferences;
DELETE FROM OrderEntryPreferences WHERE ClientID ='DEFAULT' AND Attribute ='Product';
INSERT INTO OrderEntryPreferences ('ID', 'Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES (3, 'Product', 'CNC', 'DEFAULT', 'INSTRUMENTWISE','CNC,CNC|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|CNC,CNC|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN');
DELETE FROM SYS_PARAMETER WHERE ParameterID = 32 AND ClientID ='DEFAULT';
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (32,'FALSE','DEFAULT');
DELETE FROM SYSPARAMMASTER WHERE ID = 32;
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (32,'SOR');
DELETE FROM ATTRIBUTE_MASTER where ATTRIBUTE_ID='75';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID,ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_DESCRIPTION,ATTRIBUTE_CODE) VALUES ('75','INTEROP', 'PERIODICITY','INTEROP','IP');
DELETE FROM SYS_PARAMETER WHERE ParameterID = 33 AND ClientID ='DEFAULT';
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (33,'FALSE','DEFAULT');
DELETE FROM SYSPARAMMASTER WHERE ID = 33;
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (33,'MULTISELECTIONMW');
DELETE FROM OrderEntryPreferences WHERE ClientID ='DEFAULT' AND Attribute ='MinOdrQtyFNO';
INSERT INTO OrderEntryPreferences ('Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES ('MinOdrQtyFNO', '1', 'DEFAULT', '1', 'min odr Lot for derivatives');
DELETE FROM SYS_PARAMETER WHERE ParameterID = 34 AND ClientID ='DEFAULT';
INSERT INTO SYS_PARAMETER(ParameterID,ParameterValue,ClientID) VALUES (34,'400','DEFAULT'); DELETE FROM SYSPARAMMASTER WHERE ID = 34;
DELETE FROM SYSPARAMMASTER WHERE ID = 34;
INSERT INTO SYSPARAMMASTER(ID,SYSNAME) VALUES (34,'SCRIPSEARCHDELAYTIME');
delete from INSTRUMENT_MASTER where SEGMENT_ID='3' and INSTRUMENT_ID='28';
insert into INSTRUMENT_MASTER('INSTRUMENT_ID', 'SEGMENT_ID','INSTRUMENT_NAME') values ('28','3','FUTIRC');
CREATE TABLE [MARKET_WATCH_TEMP] ( [MW_MKT_TYPE] VARCHAR(20) DEFAULT NL, [ScripIndex] BIGINT(10), [MW_LOGIN_ID] VARCHAR(50), [MW_SCRIP_ID] VARCHAR(100),[MW_SCRIP_SEGMENT] VARCHAR(10), [MW_WATCH_NAME] VARCHAR(50),  [MW_SCRIP_EXCHANGE] VARCHAR(20) DEFAULT '', [MW_SCRIP_ISIN] VARCHAR DEFAULT '', CONSTRAINT [sqlite_autoindex_MARKET_WATCH_1] PRIMARY KEY ([MW_LOGIN_ID], [MW_SCRIP_ID], [MW_SCRIP_SEGMENT], [MW_SCRIP_EXCHANGE], [MW_WATCH_NAME]));
insert into MARKET_WATCH_TEMP ([MW_MKT_TYPE], [ScripIndex], [MW_LOGIN_ID], [MW_SCRIP_ID], [MW_SCRIP_SEGMENT], [MW_WATCH_NAME]) select [MW_MKT_TYPE], [ScripIndex], [MW_LOGIN_ID], [MW_SCRIP_ID], [MW_SCRIP_SEGMENT], [MW_WATCH_NAME] from MARKET_WATCH where [MW_LOGIN_ID]!='';
drop table MARKET_WATCH;
alter table MARKET_WATCH_TEMP rename to MARKET_WATCH;
DELETE FROM SYSPARAMMASTER where SYSNAME='UPDATE_OPTIMIZEDBRDCST' AND ID='35';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (35,'35','UPDATE_OPTIMIZEDBRDCST');
DELETE FROM SYS_PARAMETER WHERE ParameterID='35' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (35,'FALSE','DEFAULT')
DELETE FROM SYSPARAMMASTER where SYSNAME='CustomDepth' AND ID='36';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (36,'36','CustomDepth');
DELETE FROM SYS_PARAMETER WHERE ParameterID='36' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (36,'','DEFAULT');
DELETE FROM SEGMENT_MASTER where EX_EXCH_ID=2 AND SEGMENT_NAME='DERIVATIVE';
INSERT INTO SEGMENT_MASTER(SEGMENT_ID,EX_EXCH_ID,SEGMENT_NAME,SEGMENT_CODE) VALUES (8,2,'DERIVATIVE','D');
DELETE FROM SEGMENT_MASTER where EX_EXCH_ID=1 AND SEGMENT_NAME='COM';
INSERT INTO SEGMENT_MASTER(SEGMENT_ID,EX_EXCH_ID,SEGMENT_NAME,SEGMENT_CODE) VALUES (10,1,'COM','M');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=35 AND SEGMENT_ID=8 AND INSTRUMENT_NAME='FUTIDX';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (35,8,'FUTIDX');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=36 AND SEGMENT_ID=8 AND INSTRUMENT_NAME='FUTSTK';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (36,8,'FUTSTK');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=37 AND SEGMENT_ID=8 AND INSTRUMENT_NAME='FUTIVX';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (37,8,'FUTIVX');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=38 AND SEGMENT_ID=8 AND INSTRUMENT_NAME='OPTIDX';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (38,8,'OPTIDX');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=39 AND SEGMENT_ID=8 AND INSTRUMENT_NAME='OPTSTK';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (39,8,'OPTSTK');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=40 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=40 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTCOM';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (40,10,'FUTCOM');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=41 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=41 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTCOM';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (41,10,'OPTCOM');
DELETE FROM Validity_Mapping WHERE Attribute_ID=1 AND ExchSegCode=28;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (1,28);
DELETE FROM Validity_Mapping WHERE Attribute_ID=2 AND ExchSegCode=28;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (2,28);
DELETE FROM ORDER_MASTER WHERE OM_EXCHSEG_CODE=28;
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (47,28,'L','Limit','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (48,28,'MKT','Market','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (49,28,'SL','SL','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (50,28,'SL-M','SL-M','B');
CREATE TABLE [OrderEntryPreferencesTemp] ( [ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Attribute] VARCHAR(200), [Value] varchaR(100), [ClientID] varCHAR(150), [CODE] varCHAR(100), [Description] vaRCHAR);
insert into OrderEntryPreferencesTemp select * from OrderEntryPreferences where [ClientID]!='';
drop table OrderEntryPreferences;
alter table OrderEntryPreferencesTemp rename to OrderEntryPreferences;
DELETE FROM OrderEntryPreferences WHERE ClientID ='DEFAULT' AND Attribute ='Product';
INSERT INTO OrderEntryPreferences ('ID', 'Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES (3, 'Product', 'CNC', 'DEFAULT', 'INSTRUMENTWISE','CNC,CNC|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|CNC,CNC|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN|MARGIN,MARGIN');
DELETE FROM SYSPARAMMASTER where SYSNAME='BUYORDER' AND ID='37';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (37,'37','BUYORDER');
DELETE FROM SYS_PARAMETER WHERE ParameterID='37' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (37,'#005186','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='SELLORDER' AND ID='38';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (38,'38','SELLORDER');
DELETE FROM SYS_PARAMETER WHERE ParameterID='38' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (38,'#A46768','DEFAULT')
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'MULTIOMSLOGIN' AND ATTRIBUTE_TYPE = 'Login';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES ('79','MULTIOMSLOGIN','Login','Multi oms login and prelogin url','FALSE|FALSE|http');
DELETE FROM SEGMENT_MASTER where EX_EXCH_ID=1 AND SEGMENT_NAME='COM';
INSERT INTO SEGMENT_MASTER(SEGMENT_ID,EX_EXCH_ID,SEGMENT_NAME,SEGMENT_CODE) VALUES (10,'1','COM','M');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=43 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=43 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTAGR';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=44 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=44 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTBAS';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=45 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTENR';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=46 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='FUTBLN';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=47 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTAGR';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=48 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTBAS';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=49 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTENR';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=50 AND SEGMENT_ID=13 AND INSTRUMENT_NAME='OPTBLN';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=43 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=43 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTAGR';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (43,10,'FUTAGR');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=44 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTCOM';
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=44 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTBAS';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (44,10,'FUTBAS');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=45 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTENR';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (45,10,'FUTENR');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=46 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='FUTBLN';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (46,10,'FUTBLN');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=47 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTAGR';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (47,10,'OPTAGR');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=48 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTBAS';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (48,10,'OPTBAS');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=49 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTENR';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (49,10,'OPTENR');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=50 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTBLN';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (50,10,'OPTBLN');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=51 AND SEGMENT_ID=6 AND INSTRUMENT_NAME='OPTFUT';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (51,6,'OPTFUT');
DELETE FROM ORDER_MASTER WHERE OM_EXCHSEG_CODE=110;
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (51,110,'L','Limit','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (52,110,'MKT','Market','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (53,110,'SL','SL','B');
INSERT INTO ORDER_MASTER(OM_ID,OM_EXCHSEG_CODE,ORD_CODE,ORD_TYPE,ORD_FLAG) VALUES (54,110,'SL-M','SL-M','B');
DELETE FROM Validity_Mapping WHERE Attribute_ID=1 AND ExchSegCode=110;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (1,110);
DELETE FROM Validity_Mapping WHERE Attribute_ID=2 AND ExchSegCode=110;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (2,110);
DELETE FROM Validity_Mapping WHERE Attribute_ID=40 AND ExchSegCode=110;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (40,110);
DELETE FROM Validity_Mapping WHERE Attribute_ID=41 AND ExchSegCode=110;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (41,110);
DELETE FROM Validity_Mapping WHERE Attribute_ID=42 AND ExchSegCode=110;
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode) VALUES (42,110);
DELETE FROM Validity_Mapping WHERE Attribute_ID=42 AND ExchSegCode=27; 
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode)VALUES(42,27);
DELETE FROM Validity_Mapping WHERE Attribute_ID=42 AND ExchSegCode=28; 
INSERT INTO Validity_Mapping(Attribute_ID,ExchSegCode)VALUES(42,28);
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'ITM' AND ATTRIBUTE_TYPE = 'PERIODICITY';
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'OTM' AND ATTRIBUTE_TYPE = 'PERIODICITY';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID,ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_DESCRIPTION,ATTRIBUTE_CODE) VALUES ('80','ITM', 'PERIODICITY','ITM','ITM');
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID,ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_DESCRIPTION,ATTRIBUTE_CODE) VALUES ('81','OTM', 'PERIODICITY','OTM','OTM');
DELETE FROM SYSPARAMMASTER WHERE ID=48 AND SYSNAME='PLACEFUNDREJECTEDORD';
DELETE FROM Validity_Mapping Where Attribute_ID = 1 AND ExchSegCode = 28;
DELETE FROM Validity_Mapping Where Attribute_ID = 1 AND ExchSegCode = 27;
DELETE FROM SYSPARAMMASTER where SYSNAME='ISORDBOOKAUTOUPDATE' AND ID='39';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (39,'39','ISORDBOOKAUTOUPDATE');
DELETE FROM SYS_PARAMETER WHERE ParameterID='39' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (39,'TRUE','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='ISNETPOSAUTOUPDATE' AND ID='40';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (40,'40','ISNETPOSAUTOUPDATE');
DELETE FROM SYS_PARAMETER WHERE ParameterID='40' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (40,'TRUE','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='ISSYSMSGAUTOUPDATE' AND ID='41';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (41,'41','ISSYSMSGAUTOUPDATE');
DELETE FROM SYS_PARAMETER WHERE ParameterID='41' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (41,'TRUE','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='NETPOSITIONSUMTIME' AND ID='42';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (42,'42','NETPOSITIONSUMTIME');
DELETE FROM SYS_PARAMETER WHERE ParameterID='42' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (42,'2','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='TRADEBOOKSUMTIME' AND ID='43';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (43,'43','TRADEBOOKSUMTIME');
DELETE FROM SYS_PARAMETER WHERE ParameterID='43' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (43,'2','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='PREOPENPERCHNGCALS' AND ID='44';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (44,'44','PREOPENPERCHNGCALS');
DELETE FROM SYS_PARAMETER WHERE ParameterID='44' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (44,'FALSE','DEFAULT');
DELETE FROM INSTRUMENT_MASTER WHERE INSTRUMENT_ID=52 AND SEGMENT_ID=10 AND INSTRUMENT_NAME='OPTFUT';
INSERT INTO INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) VALUES (52,10,'OPTFUT');
CREATE TABLE "MARKET_WATCH_Temp" ( [MW_MKT_TYPE] VARCHAR(20) DEFAULT NL, [ScripIndex] BIGINT(10), [MW_LOGIN_ID] VARCHAR(50), [MW_SCRIP_ID] VARCHAR(100),[MW_SCRIP_SEGMENT] VARCHAR(10), [MW_WATCH_NAME] VARCHAR(50),  [MW_SCRIP_EXCHANGE] VARCHAR(20) DEFAULT '', [MW_SCRIP_ISIN] VARCHAR DEFAULT '',[MW_SYMBOL] VARCHAR(200), CONSTRAINT [sqlite_autoindex_MARKET_WATCH_1] PRIMARY KEY ([MW_LOGIN_ID], [MW_SCRIP_ID], [MW_SCRIP_SEGMENT], [MW_SCRIP_EXCHANGE], [MW_WATCH_NAME])); 
INSERT INTO MARKET_WATCH_Temp (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL) SELECT MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,'' FROM MARKET_WATCH where [MW_LOGIN_ID]!='';
DROP TABLE MARKET_WATCH;
ALTER TABLE MARKET_WATCH_Temp rename to MARKET_WATCH;
DELETE FROM SYSPARAMMASTER where SYSNAME='ISSLICING' AND ID='45';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (45,'45','ISSLICING');
DELETE FROM SYS_PARAMETER WHERE ParameterID='45' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (45,'True','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='TRADINGVIEW' AND ID='46';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (46,'46','TRADINGVIEW');
DELETE FROM SYS_PARAMETER WHERE ParameterID='46' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (46,'False','DEFAULT');
DELETE FROM SYSPARAMMASTER where SYSNAME='ISMULTIDEPTHSCREEN' AND ID='47';
INSERT INTO SYSPARAMMASTER(rowid,ID,SYSNAME) VALUES (47,'47','ISMULTIDEPTHSCREEN');
DELETE FROM SYS_PARAMETER WHERE ParameterID='47' and clientid='DEFAULT';
Insert into SYS_PARAMETER(ParameterID,ParameterValue,ClientID) values (47,'False','DEFAULT');
DELETE FROM SYSPARAMMASTER WHERE ID=48 AND SYSNAME='PLACEFUNDREJECTEDORD';
INSERT INTO SYSPARAMMASTER (ID,SYSNAME)VALUES (48,'PLACEFUNDREJECTEDORD');
DELETE FROM SYS_PARAMETER WHERE ParameterID = 48 AND ClientID != 'DEFAULT';
INSERT INTO SYS_PARAMETER (ParameterID,ParameterValue,ClientID)VALUES (48,'false','DEFAULT');
DELETE FROM ATTRIBUTE_MASTER WHERE ATTRIBUTE_NAME = 'EXPIRED' AND ATTRIBUTE_TYPE = 'Order_Status';
INSERT INTO ATTRIBUTE_MASTER (ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_CODE) VALUES ('85','EXPIRED','Order_Status','','');
DELETE from INSTRUMENT_MASTER where SEGMENT_ID = '5' AND INSTRUMENT_NAME = "OPTIDX";
DELETE from INSTRUMENT_MASTER where INSTRUMENT_ID = '54';
INSERT into INSTRUMENT_MASTER(INSTRUMENT_ID,SEGMENT_ID,INSTRUMENT_NAME) values(54,'5',"OPTIDX");
DELETE FROM SYSPARAMMASTER WHERE ID=49 AND SYSNAME='MAX_MKTWATCH_SCRIP';
INSERT INTO SYSPARAMMASTER (ID,SYSNAME)VALUES (49,'MAX_MKTWATCH_SCRIP');
DELETE FROM SYS_PARAMETER WHERE ParameterID = 49 AND ClientID != 'DEFAULT';
INSERT INTO SYS_PARAMETER (ParameterID,ParameterValue,ClientID)VALUES (49,'450','DEFAULT');
DELETE from MarketWatchLimits  where Conditionalpar in ('CHGUP','CHGDO') and clientID = 'DEFAULT' and Parameter = 'FLASH'; 
INSERT into MarketWatchLimits(ClientID,Parameter,value,BCode,FCode,Conditionalpar) values ('DEFAULT' , 'FLASH', '2' , '#00FFFFFF' , '#FF1BA536' , 'CHGUP');
INSERT into MarketWatchLimits(ClientID,Parameter,value,BCode,FCode,Conditionalpar) Values ('DEFAULT' , 'FLASH', '1', '#00FFFFFF' , '#FFDA2128' , 'CHGDO');
DELETE FROM MARKET_WATCH where MW_LOGIN_ID = 'DEFAULT' and MW_WATCH_NAME = 'Indices';
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','0','DEFAULT','13','I','Indices','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','1','DEFAULT','51','I','Indices','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','2','DEFAULT','25','I','Indices','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','3','DEFAULT','50','I','Indices','','',Null);
DELETE FROM MARKET_WATCH where MW_LOGIN_ID = 'DEFAULT' and MW_WATCH_NAME = 'Index';
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','0','DEFAULT','13','I','Index','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','1','DEFAULT','51','I','Index','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','2','DEFAULT','25','I','Index','','',Null);
INSERT INTO MARKET_WATCH (MW_MKT_TYPE,ScripIndex,MW_LOGIN_ID,MW_SCRIP_ID,MW_SCRIP_SEGMENT,MW_WATCH_NAME,MW_SCRIP_EXCHANGE,MW_SCRIP_ISIN,MW_SYMBOL)VALUES ('NL','3','DEFAULT','50','I','Index','','',Null);
DELETE FROM OrderEntryPreferences WHERE  Attribute ='clientid' AND Value !='LASTCLIENT'  AND LENGTH(IFNULL(Description, '')) = 0;
INSERT INTO OrderEntryPreferences ('Attribute', 'Value', 'ClientID', 'CODE', 'Description') VALUES ('clientid', '', 'DEFAULT', 'FALSE', '');